﻿//*** Guidance generated code ***//
using System.Linq;
using System.Diagnostics.Contracts;
using System.Collections.Generic;
using System;

using ProjectBase.Core;
using ProjectBase.Core.Web;
using ProjectBase.Mvc;

namespace Survey.Filters.Restrictions
{
    public abstract class ControlRenderHandler<TEntity> : IControlRenderHandler
        where TEntity : class, IPersistentObject
    {
        public virtual Type EntityType { get { return typeof(TEntity); } }

        public virtual void Handle(IVisualControl control, PreRenderControlEventArgs args)
        {
            var controller = args.ViewContext.Controller as IWebController<IEntityModel<TEntity, IFilter>>;
            Handle(control, args, controller.Model);
        }

        protected abstract void Handle(IVisualControl control, PreRenderControlEventArgs args
            , IEntityModel<TEntity, IFilter> model);
    }
}